<template>
  <div>
    <div class="list-classify">
      <div :class="num==index?item.calas:''" @click="sel(index)" v-for="(item,index) in tablist" :key="index">{{item.title}}</div>
      <div class="list-classify-e">&nbsp;</div>
      
    </div>

    <div class="list-product">
      <ul>
        <li class="list-product-tab" v-for="(item,index) in goodList" :key="index">
          <div @click="toPath(item)" class="list-product-a">
            <img :src="item.ImgUrl" class="am-img-responsive" />
          </div>
          <div class="list-product-b" style="text-align: left;">
            <span>{{item.Name}}</span>
          </div>
          <div class="list-product-c" style="text-align: left;">
            <span>{{item.Means}}</span>
          </div>
          <div class="list-product-d" style="font-size: 0px;text-align: left;">
            <span style="color: rgb(255, 51, 0); font-size: 3.2vw; padding-left: 2vw;">￥</span>
            <span style="color: rgb(255, 51, 0); font-size: 4.267vw;">{{item.CurrentPrice}}</span>
            <span style="color: rgb(255, 51, 0); font-size: 3.2vw;">.00</span>
            <span
              style="color: rgb(153, 153, 153); font-size: 3.2vw; margin-left: 1.067vw; text-decoration: line-through;"
            >￥218</span>
            <span style="color: rgb(188, 188, 188); font-size: 3.2vw; margin-left: 1.067vw;">/ {{item.Size}}}</span>
          </div>
          <div @click="add(item)" class="list-product-e">
            <img
              src="https://res.bestcake.com\m-images-2\list-cart.png"
              class="am-img-responsive"
            />
          </div>
        </li>
      </ul>
    </div>
  
  </div>

  <!-- <div class="list-classify">
    <div class="list-classify-a">经典</div>
    <div class="list-classify-b">女神</div>
    <div class="list-classify-c">伴手礼</div>
    <div class="list-classify-e">&nbsp;</div>
  </div>-->
</template>

<script>
export default {
  data() {
    return {
      num:0,
      goodList: []
    };
  },
  props: ["tablist"],
  created() {
    this.sel(0);
  },
  methods: {
    sel(index) {
      // console.log(this.tablist[index])
      // console.log(item.list)
      this.num=index;
      this.goodList = this.tablist[index].list;
      // console.log(this.goodList)
    },
       toPath(item) {
       console.log(item);
      this.$router.push({
        path: "/show",
        query: {
          City: this.$store.state.city,
          SupplyNo: item.SupplyNo,
          Name: item.Name,
          id: item.ID
        }
      });
      //query  {City: "上海",SupplyNo:"",Name:"xxxx",id:"1878"}
    },
    add(item){
      let temp={
        City:this.$store.state.city,
        SupplyNo:item.SupplyNo,
        Name:item.Name,
        id:item.Id||item.ID,
        currentPrice:item.CurrentPrice,
        Size:item.Size
      };
      console.log(item)
      this.$store.commit("add",temp);
    }
  },
  
  watch:{
    tablist(){
      // console.log("OK")
      this.sel(0);
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.list-classify {
  margin-top: 7.466vw;
  height: 5.8667vw;
  position: relative;
  display: flex;
  justify-content: space-around;
}
.list-classify .activea {
    font-size: 4.266vw;
    font-weight: bold;
}
.list-classify .activeb {
    font-size: 4.266vw;
    font-weight: bold;
}
.list-classify .activec {
    font-size: 4.266vw;
    font-weight: bold;
}
.list-classify .actived {
    font-size: 4.266vw;
    font-weight: bold;
}
.list-classify-e {
    height: 1.6vw;
    background: linear-gradient(to right, #95d5d8 , #1fb1b9);
}
.list-classify-e {
    position: absolute;
    bottom: 0.4vw;
    transition: left 0.35s;
    z-index: 1;
}
.list-classify  .activea ~ .list-classify-e{ width: 10vw;  left:1.19rem; }
.list-classify  .activeb ~ .list-classify-e{ width: 10vw;  left:4.374rem; }
.list-classify  .activec ~ .list-classify-e{ width: 10vw;  left:7.65rem; }
.list-classify  .actived ~ .list-classify-e{ width: 10vw;  left:4.48rem; }

//商品样式
.list-product {
  width: 100vw;
  padding: 0 1.6vw;
}
.list-product-tab:nth-child(2n + 1) {
  margin-right: 8.8vw;
}
.list-product-a {
  width: 44vw;
  height: 44vw;
}
.am-img-responsive {
  display: block;
  max-width: 100%;
  height: auto;
}
.list-product-tab:nth-child(2n + 1) {
  margin-right: 8.8vw;
}
.list-product-tab {
  width: 44vw;
  float: left;
  position: relative;
  margin-bottom: 5.334vw;
}
.list-product-b {
  margin-top: 1.867vw;
  line-height: 3.734vw;
}
.list-product-c {
  width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 5vw;
}
.list-product-e {
  width: 5.334vw;
  height: 5.334vw;
  position: absolute;
  right: 0vw;
  bottom: 1vw;
}
.list-product-c span {
  font-size: 3.2vw;
  color: #999;
  padding-left: 2vw;
}
.list-product-b span {
  font-size: 3.734vw;
  color: #333;
  padding-left: 2vw;
}
.list-product-d {
  line-height: r(25);
}

</style>
